/**  \file HouseProfile.js
\brief HouseProfile animation functions

Price My House for Nokia mobile platforms.

\author © 2011 Enrico Miglino / Tech Consulting (enrico.miglino@ovi.com)
\author "Evimin Fiyati Price My House" is protected by the copyright law
\author Distributed under the LGPL 3.0 license.
\date 2011

\par Licensing notes

    "Price My House" is free software: you can redistribute it
    and/or modify it under the terms of the Lesser GNU General Public License
    as published by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    "Price My House" is distributed in the hope that it
    will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    Lesser GNU General Public License for more details.

    You should have received a copy of the Lesser GNU General Public License
    along with "Price My House".
    If not, see <http://www.gnu.org/licenses/>.

*/

/*
  changeSummaryStatus()

  Shows /hide the summary page with the current data pattern
  The summary page is set always on top of all the other pages
  to simplify its activation.
  */
function changeSummaryStatus() {
    if (!summaryView) {
        // Update the page number
        currentPage.page = maxPages+1;
        currentPage.maxPages = maxPages + 1;
        currentPage.title2 = house._summaryPageTit;
        // Set the current string for the form navigation button
        house._centerNavBtn = house._closeNavBtn;
    }
    else {
        // Update the page number
        currentPage.page = pageNum;
        currentPage.maxPages = maxPages;
        currentPage.title2 = "";
        // Set the current string for the form navigation button
        house._centerNavBtn = house._summaryPageTit;
    }
    summaryView = !summaryView;
}

/*
  setPageStatus(page, set_state)

  This function change the state of the specified page.
  The page animation in HouseProfile pages is based
  on a [left] <- [center] -> [right] sliding mechanism
  */
function setPageStatus(page, set_state) {
    switch (page) {
    case 1: form1.state = set_state; break;
    case 2: form2.state = set_state; break;
    case 3: form3.state = set_state; break;
    case 4: form4.state = set_state; break;
    case 5: form5.state = set_state; break;
    case 6: form6.state = set_state; break;
    case 7: form7.state = set_state; break;
    }
}

/*
  pageToLeft()

  Move the current page to the left side
  The page animation in HouseProfile pages is based
  on a [left] <- [center] -> [right] sliding mechanism
  */
function pageToLeft() {
    // Check for the leftmost case
    if( (pageNum - 1) > 0) pageNum--;
    else
        return; // Low end. Do nothing

    // Check for the left and right next pages
    if ( (pageNum + 1) > maxPages ) pageRight = maxPages;
    else pageRight = pageNum + 1;

    if ( (pageNum -1) < 1 ) pageLeft = 1;
    else pageLeft = pageNum - 1;

    currentPage.page = pageNum;
    currentPage.maxPages = maxPages;
    currentPage.title2 = "";
    // Hide previous page and shows the current page
    slide_pageNum(pageNum + 1, "Left");
    slide_pageNum(pageNum, "Center");
}

/*
  pageToRight()

  Move the current page to the right side
  The page animation in HouseProfile pages is based
  on a [left] <- [center] -> [right] sliding mechanism
  */
function pageToRight() {
    // Check for the leftmost case
    if( (pageNum + 1) <= maxPages) pageNum++;
    else
        return; // Low end. Do nothing

    // Check for the left and right next pages
    if ( (pageNum + 1) > maxPages ) pageRight = maxPages;
    else pageRight = pageNum + 1;

    if ( (pageNum -1) < 1 ) pageLeft = 1;
    else pageLeft = pageNum - 1;

    currentPage.page = pageNum;
    currentPage.maxPages = maxPages;
    currentPage.title2 = "";
    // Hide previous page and shows the current page
    slide_pageNum(pageNum - 1, "Right");
    slide_pageNum(pageNum, "Center");
}

